From cc4761e04197edd548f709f94134035392c62c83 Mon Sep 17 00:00:00 2001 From: "kfraser@localhost.localdomain" Date: Thu, 28 Sep 2006 11:47:33 +0100 Subject: [PATCH] [XEN] Fix i386 hypercall code to always create shadow parameters. Arguments on stack can be clobbered by callee, since it owns them. But we require this doesn't happen when we create hypercall continuations. Hence the need to copy. Signed-off-by: Keir Fraser --- xen/arch/x86/x86_32/entry.S | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/x86_32/entry.S b/xen/arch/x86/x86_32/entry.S index 06a25fa188..7ec820c7b5 100644 --- a/xen/arch/x86/x86_32/entry.S +++ b/xen/arch/x86/x86_32/entry.S @@ -175,7 +175,7 @@ ENTRY(hypercall) jae bad_hypercall PERFC_INCR(PERFC_hypercalls, %eax) #ifndef NDEBUG - /* Deliberately corrupt parameter regs not used by this hypercall. */ + /* Create shadow parameters and corrupt those not used by this call. */ pushl %eax pushl UREGS_eip+4(%esp) pushl 28(%esp) # EBP @@ -192,11 +192,23 @@ ENTRY(hypercall) movl $0xDEADBEEF,%eax rep stosl movl %esi,%eax +#else + /* + * We need shadow parameters even on non-debug builds. We depend on the + * original versions not being clobbered (needed to create a hypercall + * continuation). But that isn't guaranteed by the function-call ABI. + */ + pushl 20(%esp) # EBP + pushl 20(%esp) # EDI + pushl 20(%esp) # ESI + pushl 20(%esp) # EDX + pushl 20(%esp) # ECX + pushl 20(%esp) # EBX #endif call *hypercall_table(,%eax,4) + addl $24,%esp # Discard the shadow parameters #ifndef NDEBUG - /* Deliberately corrupt parameter regs used by this hypercall. */ - addl $24,%esp # Shadow parameters + /* Deliberately corrupt real parameter regs used by this hypercall. */ popl %ecx # Shadow EIP cmpl %ecx,UREGS_eip+4(%esp) popl %ecx # Shadow hypercall index -- 2.30.2